#include "RTMClient.h"

namespace http {
  RTMClient::RTMClient(const std::pair<std::string, std::string> &key, const std::string &uri)
    : RestClient(uri), rtmRequest(key)
  {
  }

  bool RTMClient::login(const std::string &uname, const std::string &passwd) {
    RestClient::get("/");
  }

  std::string RTMClient::getAuthURL(const std::string &perms) {
    std::map<std::string, std::string> reqMap;
    std::string authUrl = "http://www.rememberthemilk.com/services/auth/?";
    reqMap["perms"] = perms;
    reqMap["frob"] = getFrob();

    return authUrl.append(rtmRequest.setData(reqMap).getData());
  }

  std::string RTMClient::getFrob() {
    std::map<std::string, std::string> reqMap;
    reqMap["method"] = "rtm.auth.getFrob";
    return RestClient::get(rtmRequest.setData(reqMap).getData())->getBody();
  }

}
